[求助] 怎么删除不了啊? vb 操作sql的问题??急.急..................

来源:百度知道 编辑:UC知道 时间:2024/06/06 22:48:06
想要把text3和4中的内容插入表ip,在5秒后再删除,可以正常插入,可是怎么删除不了啊??? 郁闷死了....
Private Sub Command2_Click()
Dim conn As Adodb.Connection
Dim rs As Adodb.Recordset
Dim SQLstr As String
Dim StrCnn As String
Set conn = New Adodb.Connection
conn.Open "driver={sql server};database=DNS;server=(local);uid=;pwd="
Set rs = New Adodb.Recordset
rs.CursorLocation = adUseClient
SQLstr = Text4.Text
StrCnn = Text3.Text
rs.Open "INSERT INTO ip(ipaddress,domainaddress) values ('" & SQLstr & "','" & StrCnn & "') ", conn, 1, 3
Timer2.Enabled = True
If Timer2.Interval >= 5000 Then
StrCnn = Text3.Text
rs.Open "DELETE FROM ip where domainaddress='" & StrCnn & "') ", conn, 1, 3
End If
End Sub
Private Sub Command2_Click()
Dim conn As Adodb.Connection
Dim rs As Adodb.Recordset
Dim SQLstr As String
Dim StrCnn As String
Set

删除的操作写在timer事件里面
或者直接用sleep

下面这行里的")"是干啥呢?去掉试试

rs.Open "DELETE FROM ip where domainaddress='" & StrCnn & "') ", conn, 1, 3

DELETE FROM ip where domainaddress='" & StrCnn & "') ", conn, 1, 3

注意使用“)”
修改如下:

DELETE FROM ip where domainaddress='" & StrCnn & "', conn, 1, 3